from flask import Blueprint,jsonify

bp_user = Blueprint('user',__name__)

from utils.db import db1

from comm import get_data



@bp_user.route('/getuser')
def getuser():
    sql = "select * from users"

    res = db1.find_all(sql)

    return jsonify({'code':200,'list':res})



@bp_user.route('/adduser',methods=["POST"])
def adduser():
    data = get_data()

    sql = "insert into users values('%s','%s')" % (data['username'],data['password'])

    db1.update(sql)

    return jsonify({'code':200,'mes':'添加成功'})








# 职务表

@bp_user.route('/getpost')
def getpost():
    sql = "select * from posts"

    res = db1.find_all(sql)

    return jsonify({'code':200,'list':res})


@bp_user.route('/getzhiwu')
def getzhiwu():
    sql = "select * from post"

    res = db1.find_all(sql)

    return jsonify({'code':200,'list':res})
